home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 05 - 1989 / 05.08 Aug 89 / POOPDraw Code ƒ / OBJT Rect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-13  |  2.8 KB  |  113 lines  |  [TEXT/KAHL]

  1.  
  2. /********************************************************************/
  3. /*                        SOURCE CODE FILE                            */
  4. /********************************************************************/
  5. /*
  6. *   >>>    File name:        6.2 RectObject.c    
  7. *
  8. *      >>>    Purpose:        Methods for Rectangle Object
  9. *     >>>    Project:        PoopDraw    Version 1        
  10. *     >>>    Date:            2/20/89
  11. *      >>>    By:                Adam Treister
  12. *
  13. */
  14. /********************************************************************/
  15. /*    For Your Information            1802 Hillside Rd. SB CA 93101    */
  16. /********************************************************************/
  17.  
  18. #include "PoopDrawInc"
  19.  
  20. /***** Object Type Defs *********************************************/
  21.  
  22. typedef DrawObjectRec         RectObjectRec;
  23. typedef DrawObjectPtr         RectObjectPtr;
  24. typedef DrawObjectHandle     RectObjectHandle;
  25.  
  26. ObjectHandle NewRectObj(LPtr ParmP);
  27.  
  28. /***** Public Functions *********************************************/
  29. /*
  30.     ObjectHandle NewRectObj(LPtr ParmP);
  31. */
  32. /***** Private Functions ********************************************/
  33.  
  34. private ObjDispatch(DrawObjectHandle ObjectH,int Message,LPtr ParmP);
  35. private    Draw(DrawObjectHandle ObjectH);
  36.  
  37. /********************************************************************/
  38. /*------------------------------------------------------------------*/
  39.  
  40.  
  41. ObjDispatch(ObjectH,Message,ParmP)
  42. DrawObjectHandle ObjectH;
  43. int Message;
  44. LPtr ParmP;
  45.  
  46. {
  47.     switch(Message)
  48.     {
  49.         case DRAW:            Draw(ObjectH);                    break;
  50.  
  51.         default:         DrawObjectDispatch(ObjectH,Message,ParmP);
  52.     }
  53. }    
  54.  
  55. /*-------------------------------------------NEW-----------------*/
  56. /*
  57. *    Function:            --    NewRectObj
  58. *
  59. *    Date:                --    Feb. 20, 1989
  60. *    PoopDraw Version 1    --     Copyright FYI,1989 --   Adam Treister
  61. /*---------------------------------------------------------------*/
  62. ObjectHandle NewRectObj(ParmP)
  63. LPtr ParmP;
  64. {
  65.     RectObjectHandle obj;
  66.     Rect r;
  67.     
  68.     r = *(Rect *)ParmP;
  69.     SortRect(&r);
  70.     if (EmptyRect(&r))    return(NULL);
  71.     
  72.     obj = _GetHandleToRecord(RectObjectRec);
  73.     NullOutHandle(obj);
  74.     (*obj)->dispatch = ObjDispatch;
  75.     (*obj)->class = RECT;
  76.     Dispatch(obj,INIT,&r);
  77.     Dispatch(obj,INVAL,NULL);
  78.     return((ObjectHandle)obj);
  79. }
  80.  
  81.  
  82. /*-------------------------------------------method--------------*/
  83. /*
  84. *    Function:            --    RectDraw
  85. *
  86. *    Date:                --    Feb. 20, 1989
  87. *    PoopDraw Version 1    --     Copyright FYI,1989 --   Adam Treister
  88. /*---------------------------------------------------------------*/
  89.  
  90. Draw(ObjectH)
  91. RectObjectHandle ObjectH;
  92. {
  93.     if (BitTst(&(*ObjectH)->attributes,VisibleBit))
  94.     {
  95.         register DrawStateRec drawState;
  96.         Rect r;
  97.         
  98.         r = (*ObjectH)->bounds;
  99.         drawState = (*ObjectH)->drawState;
  100.         PenNormal();
  101.         PenPat(**(GetPattern(drawState.fillPat)));
  102.         PaintRect(&r);
  103.         PenPat(**(GetPattern(drawState.penPat)));
  104.         PenSize(drawState.penSize,drawState.penSize);
  105.         FrameRect(&r);
  106.  
  107.         if (BitTst(&(*ObjectH)->attributes,SelectedBit))
  108.         {
  109.                 Dispatch(SELF,DRAWHANDLES,NULL);
  110.         }
  111.     }
  112. }    
  113.